package com.example.demo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

public class AlipayConfig1 {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String appId = "2021000149616311";

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String privateKey ="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCHOIxA7m5Ilgv52BGdx2yUkpQEh2eEuu4g9pfIJ4g661JG+krwv1mIq85u07STnmwdI/IR1WI0ZuxWYo79crVFU/6EfK32aJiZUVRQ4C0FO3JchubLqRFYGnJqCJT5XSquqnLcyIZVRw0VLz1KSE2wK38sy2lWY6nvaURsxELsBm85yBaviHT6/q98CeGQnKLK49to1TaXK1IR7KuzklwsE4GmKTnjoalyHU78nMyrCddllH7vsblsCXUaakpSj/5wS0yCZnGSNwRNFgJf9/2Dga7c/tY8JSoTcvs+dnW6V2+XkBZq2s+ToW+POlzGR6Y4czB+zf+64U0JWLCBYr/JAgMBAAECggEAXNIRXMUOyR7Oq7uJJDBvtXEE0DMOeUtECTacrBWO6zr76KMJbEc9s5aUBvmmHCsEdeBl254JYoVAOHBBTXM/QY7NyK45UEsubRgp87Ze0RekgiVMKoMs17iXz3eCo8YzdWClpi60H7e9IEykGuiVA5hoHRyoe1fAoAo3oR37/j3PULT1wT2jCnLRSuOc2JaUdHs2qnOBszSGtysEFWN+YrehlaWMkIfxeqXocS/pryKl10LSau/yFTnhJjruX1373TtiRADmYHppj2FNnCHpNWDJjZsHkX5sH3RK96pjTkzourO+31hDZXpP5dak8FoMg85DAL3KbHoxCUU3KqMysQKBgQDRGANx8d9swDUGN0VF0D89k0l46hzxV9fuLOCMoMXB2PuGAeh7gZx55RXL/MUX9E/8U4zbcTzwOVNmYF+gCdVQ/bF1eJ9T5KClshxa3g1m2OSO1RRTcEaIDkkCE2nvAlnNg5Uqs10J2wnzbotAdlNAoXGz22Y3aHEBcbH9zqDNPQKBgQCljhvO+BsDDP8wFa9g54wjHZlmQiMtfD9PC90vNxWgAhsd4rp/Q1b23qzGkXeNwBuYslKbiMbZV1Xs2yYSsq9VwVy4iORYlZX+ZwQHObe1IcYHcJzkHOWvhkYq4YIWTdOzDKdbkzagBdNHYw+eG5LJstP9/WKhsughGTqWOUM9fQKBgQCKvnNyxXtq7zOAF2bJB4EfO7+SE073OkHXEkJCLmBq268y4ctBQOTy4XcQL38dAQmeNlaOOlqkUHWtxh9N05iPsHdzqoGWqmuK51/3T8b2ys8GlA9zulmi6E+7p+QwK5ApVbnCZthCtOyqclzGfn2Jslb/cIMoGw55Vdc0wkpjRQKBgQCE5GjgH3qXXVRuxcls0RFFktnzIr3YIjczfYOEBgSe13Hq8Hfh9i0Vp7MrBdPg/kdosCPtY8Ky7g80PMn4EmT6QmfqXUBm91RazViHcEZN6JlsmXHnDmc1GWSzwSdKPhjkThD9SlN76pEpaZQ8x0dyDtFqvX3x7Im3H+hOdBLMhQKBgCIqrvEH4pDDa6IvsHSIuiXUftyWmyrR4BlCknX9DUgYNxE6I3r2x0ZcPSFywFoqUGCRTcs62hBXkYPnzKkhi7faN2SXELticiufxzb8mrTzu4xxKEtxbW2wSbrjq/8iRKj5e7yRbAn/ZncnxeLaiRYqm4101sXkJSE3NH9r7AUh" ;
    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String publicKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk/ywXvjbp6/LboakAwdrhrbfTohbV3mPanblB2BGeAsx3Qmw2PZx9gvtqG/uLPgplxTql9dwO0OwC/ZfgFtRpb7mH28vo3kJtDn8JT2AaqymuDB6lfTvHVDerE5ct76EoTQgTOGzPZoPCCzZFbGGGzXyo8XvPW6lc8gjJpli4Y/Wmu7jHomfBjKz5nHVGpvS77ETtuIW6JSfnNSZQYfz6FLLTV4XvFoOa3JNDnJbwXT2SJaR9bgGUA+eAVD302SgeZvclQLGQoatHeM/ekPfwHrwJTP37OjY/wdiBw5PNDjaBqhPu/8kf83LFqBI9sq31drPNwnAQqftmWKJwYepfwIDAQAB";
    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String notify_url = "http://localhost:8080/system/order/alipay_back";


    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
//    public static String returnUrl = "http://localhost:8080/return_url.html";
    public static String returnUrl = "http://localhost:8080/system/order/alipay_back";

    // 签名方式
    public static String signType = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
    // public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
    // 支付宝网关
    public static String logPath = "C:\\";

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(logPath + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
